package io.demo.command;

/**
 * @author create by zhangpengfei at 2021/9/29 19:29
 */

public class Main {
    public static void main(String [] args){
        SimpleRemoteControl remoteControl = new SimpleRemoteControl();
        Light light = new Light();
        LightOnCommand lightOnCommand = new LightOnCommand(light);
        LightOffCommand lightOffCommand = new LightOffCommand(light);

        remoteControl.setCommand(lightOnCommand);
        remoteControl.buttonWasPressed();

        remoteControl.setCommand(lightOffCommand);
        remoteControl.buttonWasPressed();

        GarageDoor garageDoor = new GarageDoor();
        GarageDoorOpenCommand garageDoorOpenCommand = new GarageDoorOpenCommand(garageDoor);
        GarageDoorCloseCommand garageDoorCloseCommand = new GarageDoorCloseCommand(garageDoor);



        RemoteControlWithUndo remoteControlWithUndo = new RemoteControlWithUndo();
        remoteControlWithUndo.setCommand(1, lightOnCommand, lightOffCommand);
        remoteControlWithUndo.setCommand(2, garageDoorOpenCommand, garageDoorCloseCommand);

        remoteControlWithUndo.onButtonWasPushed(1);
        remoteControlWithUndo.undoCommandWasPushed();
        remoteControlWithUndo.offButtonWasPushed(1);
        remoteControlWithUndo.undoCommandWasPushed();

        remoteControlWithUndo.onButtonWasPushed(2);
        remoteControlWithUndo.undoCommandWasPushed();
        remoteControlWithUndo.offButtonWasPushed(2);
        remoteControlWithUndo.undoCommandWasPushed();
    }
}
